﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ManWebRole.Models.Account>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Manage Accounts
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Manage All Accounts</h2>

    <table>
        <tr>
            
            <th>
                Id
            </th>
             <th>
                UserName
            </th>
            <th>
                Password
            </th>
            <th>
                ProjectId
            </th>
            <th>
                Type
            </th>
            <th>Actions</th>
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr> 
            <td>
                <%: item.Id %>
            </td>
             <td>
                <%: item.UserName %>
            </td>
            <td>
                <%: item.Password %>
            </td>
            <td>
                <% if (item.ProjectId == null)
	                {
                        Response.Write("None");   
	                }
                   else
                   {
                       ManWebRole.Models.ProjectModel model = new ManWebRole.Models.ProjectModel();
                       string projectName = model.GetProjectById((int)item.ProjectId).Name;
                       Response.Write(projectName);
                   } 
                %>
            </td>
            <td>
                <% switch ((ManWebRole.Models.UserType)item.Type)
                   {
                       case ManWebRole.Models.UserType.ProjectAdmin:
                           Response.Write("Project Administrator");
                           break;
                       case ManWebRole.Models.UserType.Customer:
                           Response.Write("Project Customer");
                           break;
                       case ManWebRole.Models.UserType.None:
                           Response.Write("Unknown");
                           break;
                       case ManWebRole.Models.UserType.SRE:
                           Response.Write("Software Requirements Engineer");
                           break;
                       case ManWebRole.Models.UserType.BuiltAdmin:
                           Response.Write("Builtin Administrator");
                           break;
                       default:
                           break;
                   }%>
            </td>
             <td>
                <%: Html.ActionLink("Edit", "AccountEdit", new { id=item.Id }) %> |
                <%: Html.ActionLink("Details", "AccountDetails", new { id=item.Id })%> |
                <%: Html.ActionLink("Delete", "AccountDelete", new { id=item.Id })%>
            </td>
        </tr>
    
    <% } %>

    </table>

    <p>
        <%: Html.ActionLink("Create New", "AccountCreate")%>
    </p>

</asp:Content>

